package com.aifast.system.sys.dao;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.aifast.system.sys.entity.SysTenantPackage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
 * 租户套餐Mapper接口
 *
 * @author fujian
 * @date 2022-10-30
 */
@Mapper
public interface SysTenantPackageDao extends BaseMapper<SysTenantPackage> {

    default LambdaQueryWrapper<SysTenantPackage> select(Integer tenantId, String name, Integer state) {
        return new LambdaQueryWrapper<SysTenantPackage>()
                .eq(ObjectUtil.isNotNull(tenantId), SysTenantPackage::getTenantId, tenantId)
                .like(StrUtil.isNotBlank(name), SysTenantPackage::getName, name)
                .eq(ObjectUtil.isNotNull(state), SysTenantPackage::getState, state)
                .orderByDesc(SysTenantPackage::getId);
    }

}
